package com.knight.circular.references;

import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

public class SpringClientBean {

    public static void main(String[] args) {
        Resource resource = new ClassPathResource("bean-circular-eferences.xml");

        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        BeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);

        int num = beanDefinitionReader.loadBeanDefinitions(resource);

        Student student = beanFactory.getBean("student", Student.class);
        System.out.println(student);
        Desk desk = beanFactory.getBean("desk", Desk.class);
        System.out.println(desk);
    }
}
